'use strict';
var Schema = require('mongoose').Schema,
    Model = require('../../../Base/server/controllers/Model');

var modelField = {};
modelField.Code = {
    type: String,
    Name: '编码',
    IsUnique: true,
    IsEmpty: false,
    trim: true
};
//当前状态 0: 开工 1：上线 2：完工 3：下线
modelField.Status = {
    type: Number
};
//批号
modelField.LotNumber = {
    type: String,
    trim: true
};

//客户
modelField.Customer = {
    type: String,
    trim: true
};
//工厂
modelField.Factory = {
    type: String,
    trim: true
};

//物料
modelField.ItemMaster = {
    type: Schema.ObjectId,
    ref: 'ItemMaster',
    Name: '料品',
    IsEmpty: false
};
//生产数量
modelField.Qty = {
    type: Number,
    Name: '生产数量',
    IsEmpty: false
};
//累计完工量
modelField.TotalCompleteQty = {
    type: Number
};
//开工日期
modelField.StartDateTime = {
    type: Date,
    Name: '开工日期',
    IsEmpty: false
};
//完工日期
modelField.EndDateTime = {
    type: Date,
    Name: '完工日期',
    IsEmpty: false
};
//实际开工日期
modelField.ActualStartDateTime = {
    type: Date
};
//实际完工日期
modelField.ActualEndDateTime = {
    type: Date
};
//上线数量
modelField.OnlineQty = {
    type: Number
};
//ERP MO.ID
modelField.ErpId = {
    type: String,
    trim: true
};
modelField.Remark = {
    type: String,
    default: '',
    trim: true
};

var newModel = new Model(modelField);
newModel.addIndex({Code: 1});
newModel.create('MO', '生产订单');
